<?php
declare (strict_types = 1);
namespace app\course\model\classes\admin;

use app\common\model\BaseModel;
use app\course\model\base\admin\Course;

/**
 * 班级课程-关联课程--后台管理
 */
class ClassesLink extends BaseModel
{
    protected $name = 'course_classes_link';
    /**
     * 设置自动写入时间
     * @var boolean
     */
    protected $autoWriteTimestamp = true;

    /**
     * 不需要更新时间
     * @var boolean
     */
    protected $updateTime = false;
    /**
     * 定义字段类型
     * @var array
     */
    protected $type = [
        'id'          => 'integer',
        'classes_id'  => 'integer',
        'course_id'   => 'integer',
    ];
    /**
     * 时间显示格式
     * @var string
     */
    protected $dateFormat = 'Y-m-d H:i';

    /**
     * 关联课程
     * Author   Martinsun<syh@sunyonghong.com>
     * Date 2020-06-29
     * @return   [type]                         [description]
     */
    public function course()
    {
        return $this->belongsTo(Course::class, 'course_id')->with(['cover_url'])->append(['course_type_text', 'user_price']);
    }

}
